<%@ page language="java" errorPage="/CustomError.jsp"
	pageEncoding="UTF-8"%>
<%
	request.getRequestDispatcher("/jsp/BaseInclude.jsp").include(
			request, response);
%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>

<%
	response.setHeader("Pragma", "no-cache");
	response.setHeader("Cache-Control", "no-store"); // no-cache, must-revalidate, max-age=0,post-check=0, pre-check-0");
	response.setDateHeader("Expires", 0);
	String path = request.getContextPath();
	String sessionId = session.getId();
	String pageFrom = request.getParameter("pagefrom");

	String errrorMessage = (String) request
			.getAttribute("errorMessage");
	if (errrorMessage == null || errrorMessage.equals(""))
		errrorMessage = (String) request.getParameter("errorMessage");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title><bean:message key="login.titile" /></title>

		<script type="text/javascript" language="javascript"
			src="<%=path%>/include/lib/jquery.js"></script>
		<script type="text/javascript" language="javascript"
			src="<%=path%>/include/lib/curvycorners.js"></script>
		<script type="text/javascript" language="javascript"
			src="<%=path%>/include/lib/link.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/include/lib/md5.js">

   </script>
		<script type='text/javascript' src='<%=path%>/include/lib/utils.js'></script>
		<SCRIPT language="javascript">
   var pageFrom = "<%=pageFrom%>";
   var errrorMessage = "<%=errrorMessage%>";
   var keysCaps = "false";
//  for disabling back button
//    window.history.go(1);
   
   function loader() { 
	//	self.focus(); //Bring window to foreground if necessary. 
		var form = document.forms[0]; // grab the first form available. 
		form.setAttribute("autocomplete","off"); // Turn off Autocomplete for the form, if the browser supports it. 
		//form.elements[0].focus(); // Send the cursor to the first field of the first form 
	} 
   
   
   
   window.onload = function()
	{
		if(errrorMessage == null || errrorMessage == "" || errrorMessage == "null") {
			if(pageFrom != "Y") {
				
			}
		}
		document.all.loginid.focus();
		document.all.uipassword.value = "";
		document.all.password.value = "";
		//to turn off autocomplete feature of the browser for the current form.
		loader();
	}
	function submitForm()
	  {
		  var loginId = document.all.loginid.value;
		  var pwd = document.all.uipassword.value;
		 
		  if ( null == loginId || loginId == "" )
		  {
		  	window.alert("User Id cannot be blank");
		  	document.all.loginid.focus();
		  	return false;
		  }
		  
		  if (null == pwd || pwd == "")
		  {
		 		 window.alert("Password cannot be blank");
		 		 document.all.uipassword.focus();
		  	return false;
		  }                          
		   
		document.all.password.value = hex_md5(pwd) + hex_md5('<%=sessionId%>');
		document.all.password.value = hex_md5(document.all.password.value);
		
		document.all.uipassword.value = "";

		return true;
	  }
		  
	  function resetdata()
		{
			document.all.loginid.value = "";
			document.all.uipassword.value = "";
			document.all.password.value = "";
			document.all.loginid.focus();
			return false;
		} 
	
   </SCRIPT>

	</head>
	<body>
		<form action="<%=path%>/jsp/common/CommonsListAddItem.jsp"
			method="post" onsubmit="return submitForm()">
			<div id="main">
				<jsp:include page="Logo.jsp"></jsp:include><div id="top-blue-line"></div>
				<div id="margin-top">
					<div id="content">
						<div id="wid-228">
							<div id="myBox">
								<div class="pad-left">
									<span class="blue-bold"><bean:message key="securelogin" />
									</span>
								</div>

								<logic:present name="errorMessage" scope="request">
									<div class="error-div">
										<span class="error">Login Error!</span>
										<br />
										<span class="error-txt"><bean:write name="errorMessage" />
										</span>
									</div>
								</logic:present>

								<div class="pad-left">
									<span class="bold-11"><bean:message key="userid" /> </span>
									<br />
									<html:text property="loginid" alt="Enter LoginID"
										styleClass="field-login" maxlength="25" />
								</div>
								<div class="pad-left">
									<span class="bold-11"><bean:message key="password" /> </span>
									<br />
									<input type="password" name="uipassword" alt="Enter password"
										class="field-login" onKeyDown="return DisableCtrlKey(event)"
										maxlength="50" />
									<html:hidden property="password" value="" />
									<html:hidden property="sessionid" value="<%=sessionId%>" />
								</div>
								<div class="pad-left">
									<input name="Input" id="Input" type="checkbox" value="vb"
										onclick="showoption(); " />
									&nbsp;
									<span class="key">Use Virtual Keyboard</span>
									<br />
									<div class="recc-pad">
										<span class="pink-b">(Recommended)</span>
									</div>
								</div>
								<div class="pad-left">
									<br />
									<html:submit property="submit" styleClass="submit"
										style="cursor:pointer">
										<bean:message key="login.titile" />
									</html:submit>
									<a href="#"><input type="button" id="Reset" title="Reset"
											name="Reset" style="cursor: pointer" class="submit"
											value="Reset" onclick="resetdata();" /> </a>
									<br>
									<br>

								</div>

								<div class="login-error">
									<html:errors />
								</div>
							</div>



						</div>
						<!-- PRADEEP END -->
						<div class="clr"></div>
					</div>

					<div class="welcome">
						&nbsp;Welcome
						<br />
						<br />
						<br />
						<img src="<%=path%>/images/Login.jpg" width="383" height="285" />
						<br />
						<br />
					</div>
				</div>
			</div>
		
		</form>
		<jsp:include page="Footer.jsp" />
	</body>
</html>
